package com.lh.music.test;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lh.music.R;

import java.util.List;

/**
 * Created by a on 2016/12/27.
 */

public class LinearAdapter extends RecyclerView.Adapter<LinearAdapter.LinearViewHolder> {
    private List<String> mData;
    private Context context;

    public LinearAdapter(Context context,List<String> mData) {
        this.mData = mData;
        this.context = context;
    }

    @Override
    public LinearViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView= LayoutInflater.from(context)
                .inflate(R.layout.adapter_recycle,null);
        LinearViewHolder holder=new LinearViewHolder(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(LinearViewHolder holder, int position) {
        holder.title.setText(mData.get(position));
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    public class LinearViewHolder extends RecyclerView.ViewHolder{
        TextView title;
        public LinearViewHolder(View itemView) {
            super(itemView);
            title= (TextView) itemView.findViewById(R.id.title);
        }
    }
}
